#define _CRT_SECURE_NO_WARNINGS 1
#include<string>
#include <vector>
using namespace std;
class Solution {
public:
    string trans(string s, int n)
    {
        s.push_back(' ');
        vector<string> vs;
        int i = 0;
        string tmp;
        for (int i = 0;i < s.size();++i)
        {
            if (s[i] == ' ')
            {
                //cerr<<"tmp="<<tmp<<endl;
                vs.push_back(tmp);
                tmp.resize(0);
            }
            else
            {
                if (s[i] >= 'a' && s[i] <= 'z')
                {
                    tmp += (s[i] - 'a' + 'A');
                }
                else
                {
                    tmp += (s[i] - 'A' + 'a');
                }
            }
        }
        string ret;
        //cerr<<ret<<endl;
        //cerr<<"vs[i]="<<vs[0]<<endl;
        for (int i = vs.size() - 1;i >= 0;--i)
        {
            //cerr<<"i="<<i<<endl;
            //cerr<<"vs[i]="<<vs[i]<<endl;
            ret += vs[i] + " ";
            //cerr<<ret<<endl;
        }
        ret.pop_back();
        return ret;
    }
};